﻿@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: true *@

@inherits LogDashboard.Views.RazorPage

@using System.Collections.Generic
@using LogDashboard.Extensions
@using LogDashboard.Models


<div class="table-responsive">
    <table class="table row mx-0">
        <thead class="w-100">
            <tr class="row mx-0">
                <th class="col-1">Id</th>
                <th class="col-3">Logger</th>
                <th class="col-1">级别</th>
                <th class="col-4">消息</th>
                <th class="col-2">时间</th>
                <th class="col-1">详情</th>
            </tr>
        </thead>    
        <tbody class="w-100">
            @foreach (var item in (IEnumerable<ILogModel>)ViewData["Model"])
            {
                <tr class="row mx-0">
                    <td class="col-1"><a href="javascript:void(0);" onclick="logInfo('@item.Id.ToString()')">@item.Id.ToString()</a></td>
                    <td class="col-3">@item.Logger</td>
                    <td class="col-1"><button class="btn btn-outline-@item.Level.ToUpper()">@item.Level.ToUpper()</button></td>
                    <td class="col-4" onclick="$(this).next().show(); $(this).css('display','none');">
                        @{
                            var message = item.Message;
                            if (message.Length > 90)
                            {
                                message = message.Substring(0, 90) + "........";
                            }
                        }
                        @message
                    </td>
                    <td class="col-4" style="display: none;" onclick="$(this).prev().show(); $(this).css('display','none');">@item.Message</td>
                    <td class="col-2">@item.LongDate.ToString("yyyy-MM-dd HH:mm:ss")</td>
                    <td class="col-1"><a href="javascript:void(0);" onclick="logInfo('@item.Id.ToString()-info','logInfoModal','logInfoBody')">详情</a></td>
                    <div style="display: none" id="@item.Id.ToString()-info">@item.ToJsonString()</div>
                </tr>
            }
        </tbody>
    </table>
</div>
<div class="modal fade show" id="logInfoModal" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">日志详情</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body" id="logInfoBody">

            </div>
        </div>
    </div>
</div>
